function [s_hat,signal] = optimal_detector_qpsk(h,r,rho,nt)


code_length=nt*2;
min=1000000000000;
signal=[];
s_hat=[];
for a=0:(power(2,code_length)-1)

	z=int2bin(a,code_length);

	s=zeros(nt,ceil(length(z)/2/nt));

	for n=1:2:length(z)
		row=mod(floor((n-1)/2),nt)+1;
		col=floor(n/2/nt)+1;
		s(row,col)=bin2qpsk([z(n) z(n+1)]);
	end
	residue=norm(abs(r-sqrt(rho/nt)*h*s));
	if(residue<min)
		min=residue;
		s_hat=s;
		signal=z;
	end
end



	


	